package com.ophiux.FeverManagement.infratructure.repository;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ophiux.FeverManagement.domain.entity.RbDoctorThirdparty;
import com.ophiux.FeverManagement.domain.repository.IDoctorThirdpartyRepositories;
import com.ophiux.FeverManagement.infratructure.mapper.RbDoctorThirdpartyMapper;
import com.ophiux.utils.common.StringUtil;
import com.ophiux.utils.exception.OphiuxRepositoryException;

import lombok.extern.slf4j.Slf4j;
@Repository
@Slf4j
public class DoctorThirdpartyRepositoriesImpl implements IDoctorThirdpartyRepositories{
	@Autowired
	RbDoctorThirdpartyMapper doctorThirdpartyMapper;
	
	@Override
	public String save(RbDoctorThirdparty model) throws OphiuxRepositoryException {
		if(model == null) {
			return null;
		}
		String id = "";
		try {
			if(StringUtil.isEmpty(model.getID())) {//新增
				id =  UUID.randomUUID().toString().replaceAll("-", "");
				model.setID(id);
				doctorThirdpartyMapper.insert(model);
			}else {
				id = model.getID();
				doctorThirdpartyMapper.update(model);
			}
		}catch (Exception e) {
			e.printStackTrace();
			log.info("DoctorThirdpartyRepositoriesImpl=>save(),数据库执行异常,异常信息",e);
			throw new OphiuxRepositoryException("DoctorThirdpartyRepositoriesImpl=>save(),数据库执行异常");
		}
		
		return id;
	}

	@Override
	public void delete(Object uniqueId) throws OphiuxRepositoryException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public RbDoctorThirdparty selectOneByKey(Object uniqueId) throws OphiuxRepositoryException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public RbDoctorThirdparty selectOne(Map map) throws OphiuxRepositoryException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RbDoctorThirdparty> selectAll(Map map) throws OphiuxRepositoryException {
		// TODO Auto-generated method stub
		return null;
	}

}
